package com.aerors.DataProcess;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 执行本地命令
 * @author wx
 *
 */
public class CommandExector {

	public static void execCommand(String command) {
		Process p = null;
		try {
			System.out.println("command:" + command);
			p = Runtime.getRuntime().exec(command);
			String s = null;
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
			while ((s = bufferedReader.readLine()) != null) {
				System.out.println(s);
			}
			p.waitFor();
		} catch (Exception e) {
			System.out.println(e.getCause() + ";" + e.getMessage());
		}finally {
			p.destroy();
		}
		System.out.println("command:" + command + " finished");
	}
}
